import { Form, Input } from "antd";
import React, { useEffect } from "react";

export default function EditInput({
    editing = false,
    dataIndex,
    title,
    inputRef,
    save,
    toggleEdit,
    children
}) {

    return (
        <>
            {
                editing ? <Form.Item
                    style={{
                        margin: 0,
                    }}
                    name={dataIndex}
                    rules={[
                        {
                            required: true,
                            message: ``,
                        },
                    ]}
                >
                    <Input
                        ref={inputRef}
                        onPressEnter={save}
                        onBlur={save}
                     
                    />
                </Form.Item>
                    :
                    <div
                        className="editable-cell-value-wrap"
                        style={{
                            paddingRight: 24,
                            minHeight:32
                        }}
                        onClick={toggleEdit}
                    >
                        {children}
                    </div>
            }

        </>
    )
}